import { createRouter, createWebHistory } from "vue-router";
import index from "../views/index.vue";
import login from "../views/login.vue";
import register from "../views/usersInfo/register.vue";
import iIndex from "../views/usersInfo/iIndex.vue";
import rePwd from "../views/usersInfo/rePwd.vue";
import searchCircuit from "../views/circuitInfo/searchCircuit.vue";
import settingCircuit from "../views/circuitInfo/settingCircuit.vue";
import algorithm from "../views/algorithm/algorithm.vue";
import calculation from "../views/simulation/calculation.vue";
import validation from "../views/simulation/validation.vue";
import resultsQuery from "../views/results/resultsQuery.vue";
import simulationResults from "../views/results/simulationResults.vue";
import oldSimulation from "../views/results/oldSimulation.vue";
import score from "../views/AI/score.vue";
import task from "../views/task/index.vue";
import NewSettingCircuit from "@/views/circuitInfo/newSettingCircuit.vue";
import TestDemo from "@/views/test/testDemo.vue";
const routes = [
  {
    path: "/",
    component: login,
  },
  {
    path: "/index",
    redirect: "index/iIndex",
  },
  {
    path: "/register",
    component: register,
  },
  {
    path: "/test",
    component: index,
    children: [
      {
        path: "demo",
        component: TestDemo,
        name: "模拟测试",
        meta: { keepAlive: true },
      },
    ],
  },
  {
    path: "/index",
    component: index,
    children: [
      {
        path: "iIndex",
        component: iIndex,
        name: "主页总览",
        meta: { keepAlive: true },
      },
      {
        path: "rePwd",
        component: rePwd,
        name: "修改密码",
      },
    ],
  },
  {
    path: "/algorithm",
    component: index,
    children: [
      {
        path: "demo",
        component: algorithm,
        name: "算法配置",
        meta: { keepAlive: true },
      },
    ],
  },
  {
    path: "/circuit",
    component: index,
    children: [
      {
        path: "searchCircuit",
        component: searchCircuit,
        name: "电路搜索",
        meta: { keepAlive: true },
      },
      {
        path: ":circuitName/settingCircuit",
        component: settingCircuit,
        name: "电路配置",
        meta: { keepAlive: true },
      },
      {
        path: ":circuitName/newSettingCircuit",
        component: NewSettingCircuit,
        name: "电路设置",
        meta: { keepAlive: false },
      },
    ],
  },
  {
    path: "/simulation",
    component: index,
    children: [
      {
        path: "calculation",
        component: calculation,
        name: "仿真演算",
        meta: { keepAlive: true },
      },
      {
        path: "validation",
        component: validation,
        name: "仿真验证",
        meta: { keepAlive: true },
      },
    ],
  },
  {
    path: "/results",
    component: index,
    children: [
      {
        path: "resultsQuery",
        component: resultsQuery,
        name: "参数结果查询",
        meta: { keepAlive: true },
        props: (route) => ({
          rowData1: route.query.rowData1
            ? JSON.parse(route.query.rowData1)
            : null,
        }),
      },
      {
        path: "simulationResults",
        component: simulationResults,
        name: "仿真类型查询",
        meta: { keepAlive: true },
        props: (route) => ({
          rowData: route.query.rowData ? JSON.parse(route.query.rowData) : null,
        }),
      },
      {
        path: "oldSimulation",
        component: oldSimulation,
        name: "仿真结果查询",
        meta: { keepAlive: false },
        props: (route) => ({
          rowData: route.query.rowData ? JSON.parse(route.query.rowData) : null,
        }),
      },
    ],
  },
  {
    path: "/AI",
    component: index,
    children: [
      {
        path: "score",
        component: score,
        name: "人工调参",
        meta: { keepAlive: true },
        props: (route) => ({
          rowData: route.query.rowData ? JSON.parse(route.query.rowData) : null,
        }),
      },
    ],
  },
  {
    path: "/task",
    component: index,
    children: [
      {
        path: "index",
        component: task,
        name: "任务状态",
        meta: { keepAlive: true },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(""),
  routes,
});

export default router;
